import apiClient from '@/apis/axios.js';

/**
 * 登录接口
 * @param {string} userAccount - 用户账户
 * @param {string} password - 密码
 * @param {string} loginType - 登录类型
 * @param {string} permissionType - 权限类型
 * @returns {Promise} - 返回登录结果的 Promise
 */

export class AuthApi {
    static async login(params) {
        const { userAccount, Password, loginType="password", permissionType="666" } = params;
        try {
            const response = await apiClient.post('/login', {
                userAccount,
                Password,
                loginType,
                permissionType
            });
            return response;
        } catch (error) {
            throw new Error(error.message);
        }
    }

    static async register(params) {
        const { userAccount, Password, loginType="666", permissionType="666" } = params;
        try {
            const response = await apiClient.post('/register', {
                userAccount,
                Password,
                loginType,
                permissionType
            });
            return response;
        } catch (error) {
            throw new Error(error.message);
        }
    }

    static async logout() {}

    static async fetchUserInfo(userid){
        try {
            const response = await apiClient.post('/get_userinfo',{
                userid: userid,
            });
            return response;
        } catch (error) {
            throw new Error(error.message);
        }
    }
}
